package org.meb.speedway.model.event;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.ForeignKey;

@Entity
@Table(name = "t_heat")
@Getter
@Setter
public class Heat implements Serializable {

	public enum Gate {
		A, B, C, D
	}

	private static final long serialVersionUID = 4773515646907651760L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Version
	private Long version;

	@Column(nullable = false)
	private Integer no;

	@ManyToOne(optional = false)
	@JoinColumn(name = "event_id")
	@ForeignKey(name = "HEAT_MEAT_FK")
	private Event event;

	@Column(length = 20, nullable = false)
	@Enumerated(EnumType.STRING)
	private HeatStatus status = HeatStatus.UPCOMING;

	@OneToMany(mappedBy = "heat")
	private List<HeatComp> heatDetails;
}
